class GramRobot{

    constructor(){
        this.seriesDataY=[];
        this.seriesData=[];
        for (let i = 0; i < 360; i += 1) {
           let y= this.func(i*2);
           this.seriesDataY.push(y);
           this.seriesData.push([2*i, y]);
        } 
        this.option.series[0].data=this.seriesData;
        this.maxY=-70;
        this.minY=70;
    }


    option = {
        animation: false,
        grid: {
          top: 40,
          left: 50,
          right: 40,
          bottom: 50
        },
        xAxis: {
          type: 'value',
          name: 't',
          interval: 90, 
          min: 0,
          max: 720,
        },
        yAxis: {
          type: 'value',
          name: 'load',
          min: -70, // 最小值
          max: 70,
          interval: 40,
        },
        series: [
          {
            type: 'line',
            showSymbol: false,
            clip: true,
            data: []
          }
        ]
     };

     
    setParam(minY,maxY){
      this.minY=minY;
      this.maxY=maxY;
    }

    
    nextSeries() {
        this.seriesDataY.push(this.seriesDataY.shift())
        for (let i = 0; i < this.seriesData.length; i++) {
            this.seriesData[i][1]=this.seriesDataY[i]
            //this.seriesData[i][0]=xxx；
        }
    }


    func(x) {
        return  40*Math.sin(x/57.2);
    }


    getNextOption(nextCount){
        for(let i=0;i<nextCount;i++){
          this.nextSeries()
        }
        this.option.yAxis.max=this.maxY;
        this.option.yAxis.min=this.minY;
        this.option.series[0].data=this.seriesData;
        return this.option;
    }


}